package com.easylinkin.linkappapi.device.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easylinkin.linkappapi.device.entity.SprayRecords;
import com.easylinkin.linkappapi.device.entity.vo.SprayRecordsVo;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;

/**
 * SprayRecords表数据库访问层
 *
 * @author CodeGenerator
 * @date 2022/06/27
 */
public interface SprayRecordsMapper extends BaseMapper<SprayRecords> {


    /**
     * 查询分页
     *
     * @param page        分页参数对象
     * @param appSprayRecords 过滤参数对象
     * @return 查询分页结果
     */
    IPage<SprayRecords> findPage(Page page, @Param("appSprayRecords") SprayRecordsVo appSprayRecords);

    /**
     * 查询单条
     *
     * @param id 主键id
     * @return 查询结果
     */
    SprayRecords getOneById(@Param("id") Serializable id);

    /**
     * 查询趋势图
     * @param appSprayRecords
     * @return
     */
    List<SprayRecords> getTrend(SprayRecords appSprayRecords);

    /**
     * 查询无结束时间的喷淋记录
     * @param deviceId
     * @return
     */
    List<SprayRecords> findNoEndTimeByDeviceCode(String deviceCode);

    /**
     * 查询喷淋时长
     * @param sprayRecords
     * @return
     */
    Double getSprayHoursByTime(SprayRecordsVo appSprayRecords);

    /**
     * 查询日均喷淋时长
     * @param sprayRecords
     * @return
     */
    Double getAvgDaySprayHours(SprayRecordsVo appSprayRecords);

    SprayRecords getLatestRecord(SprayRecordsVo sprayRecords);

    /**
     * 运行报告统计
     * @param tenantId
     * @param time
     * @return
     */
    List<SprayRecords> find4Report(@Param("tenantId") String tenantId, @Param("time") Date time);
}

